﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AiShow.BLL;
using AiShow.Common;
using AiShow.IBLL;

namespace AiShow.WebSite
{
    /// <summary>
    /// 评论发布处理程序
    /// </summary>
    public class DiscussPublishHandler : IHttpHandler
    {
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var videoId = context.Request.QueryString["id"];
            var discuss = new AiShow.Model.Discuss
            {
                Avatar = context.Request.Form["Avatar"],
                Content = context.Request.Form["Content"],
                NickName = context.Request.Form["NickName"],
                ReplayTo = context.Request.Form["ReplayTo"],
                AddTime = TimeHelper.GetTimeByUnix(long.Parse(context.Request.Form["AddTime"]))
            };
            //// 添加
            IDiscussManager discussManager = new DiscussManager();
           
            discussManager.Add(videoId, discuss);
            // 返回结果

            context.Response.ContentType = "text/plain";
            context.Response.Write("ok");
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}